#include #include #include using std::string; using std::cout; using std::cin; using std::endl; //intrinsic - fundamental - built-in (char, int, float, bool, double) //user defined types (UDT) - string, ostream ... //ADT Abstract data type - data and operations for the data namespace justiceLeague { struct Height { int feet; int inches; void get() { cout << "Height (ft in)? "; cin >> feet; cin >> inches; } void display() { cout << "Height (ft in)? " << feet << "' "; cout << inches << "\"" << endl; } }; //our first datatype //struct - structure struct SuperHero { string name; string secretIdentity; string power; float weight; Height height; void get() { cout << "Name? "; getline(cin, name); cout << "Secret Identity? "; getline(cin, secretIdentity); cout << "Power? "; getline(cin, power); cout << "Weight? "; cin >> weight; height.get(); } void display() { cout << "Name: " << name << endl; cout << "Secret Identity? " << secretIdentity << endl; cout << "Power? " << power << endl; cout << "Weight? " << weight << endl; height.display(); } //... }; } //attributes, data-members, members, member variables using namespace justiceLeague; void getSuperHero(SuperHero& superHero) { cout << "Name? "; getline(cin, superHero.name); cout << "Secret Identity? "; getline(cin, superHero.secretIdentity); cout << "Power? "; getline(cin, superHero.power); cout << "Weight? "; cin >> superHero.weight; cout << "Height (ft in)? "; cin >> superHero.height.feet; cin >> superHero.height.inches; } void displaySuperHero(const SuperHero& superHero) { cout << "Name: " << superHero.name << endl; cout << "Secret Identity? " << superHero.secretIdentity << endl; cout << "Power? " << superHero.power << endl; cout << "Weight? " << superHero.weight << endl; cout << "Height (ft in)? " << superHero.height.feet << "' "; cout << superHero.height.inches << "\"" << endl; } void main() { SuperHero superHero; getSuperHero(superHero); displaySuperHero(superHero); superHero.get(); superHero.display(); Height h; h.get(); }